package testcases;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;

import org.junit.Test;

import setting.BioNLPSettings;
import util.QuickSort;
import util.io.FileUtil;

public class ParseTester {
	
	@Test public void test(){
//		BioNLPDocument doc = new BioNLPDocument("", "9989503");
//		double[]a = new double[]{12,3,4,5,6};
//		QuickSort.quicksort(a);
		float a= 0.736983842f, b = 0.578169014f;		
		System.err.println(2*a*b/(a+b));
		String[] depTexts = FileUtil.getTextFromFile("9341756.dep").split("\n");
		System.err.println(" s:2 5:3".split(" ").length);
		
		
		
		String text = "T20	Positive_regulation 743 752	increased\n"+
"T21	Protein_catabolism 753 764	 degradation\n"+
"T25	Positive_regulation 1142 1152   detectable\n"+
"T24	Protein_catabolism 1093 1104    degradation\n"+
"T26	Gene_expression 1157 1167	  expression\n"+
"T22	Gene_expression 419 428 expressed\n"+
"T23	Positive_regulation 198 205	induces\n"+
"T19	Positive_regulation 1084 1092   enhanced\n"+
"T18	Gene_expression 856 866 expressing\n"+
"E1	 Gene_expression:T18 Theme:T4\n"+
"E2	 Protein_catabolism:T24 Theme:T11\n"+
"E3	 Positive_regulation:T19 Theme:E2\n"+
"E4	 Protein_catabolism:T21 Theme:T3\n"+
"E5	 Positive_regulation:T20 Theme:E4\n"+
"E6	 Gene_expression:T22 Theme:T2\n"+
"E7	 Positive_regulation:T23 Theme:T1\n"+
"E8	 Gene_expression:T26 Theme:T12\n"+
"E9	 Positive_regulation:T25 Theme:E8\n";
		List<String> lines = Arrays.asList(text.split("\n"));
		Collections.sort(lines, new Comparator<String>(){
			@Override
			public int compare(String o1, String o2) {
				if (o1.length() <1){
					return 1;
				}
				if (o2.length() <1){
					return -1;
				}
				String t1 = o1.substring(0, o1.indexOf("\t")).replace("T", "").replace("E", "9");
				String t2 = o2.substring(0, o2.indexOf("\t")).replace("T", "").replace("E", "9");
				
				return Integer.parseInt(t1)-Integer.parseInt(t2);
			}
		});
		System.err.println(lines);

//		System.out.println(line.substring(86,94));
//		System.out.println(line.substring(149,154));
//		List<DependencyPath> paths = parse.getDependencyPath(86, 94, 149, 154);
//		System.out.println(paths.size());
//		for (DependencyPath path: paths){
//			System.out.println(path);
//		}

		String line = "adfk; (iv) sdafkl; and (v) dkjfkd";
		Matcher m = BioNLPSettings.clauseSplitter.matcher(line);
		while (m.find()){
			System.err.println(m.group());
		}

		//		Dependency dep = new Dependency();
		//		dep.buildFromString("nsubjpass(inhibited-9, Binding-1)");
		//		System.out.println(dep);
	}

//	static final String parseString = FileUtil.getTextFromFile("parseTest");
//	static final String depString = FileUtil.getTextFromFile("depTest");
}
